#include <vector>
#include <stack>

using namespace std;

class Solution
{
public:
    vector<int> finalPrices(vector<int> &prices)
    {
        vector<int> ret;
        for (int i = 0; i < prices.size(); ++i)
        {
            int num = prices[i];
            for (int j = i + 1; j < prices.size(); ++j)
            {
                if (prices[j] <= num)
                {
                    num -= prices[j];
                    break;
                }
            }
            ret.push_back(num);
        }
        return ret;
    }
};
